<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="t_a" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 工作时间计算 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="开始时间" prop="begin_day">
              <el-date-picker v-model="t_a.begin_day" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <div class='el-form-item__label'>日期格式2016-07-12 08:00:00</div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="时长" prop="begin_time">
              <el-input v-model="t_a.begin_time" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="结果" prop="">
              {{work_time}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="开始时间" prop="">
              {{getDateString(t_a,'time')}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="开始时长" prop="">
              {{t_a.time2}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="workTimeTestSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>计算</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 工作时间 </span>
      </div>
      <el-table :data="infolist">
        <el-table-column label="日期" prop="work_day">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/oa/system/EverydayTest?CMIDwork_day='+scope.row.work_day+'&cpopup=reload'+vueparams+'')" type='primary'>{{scope.row.work_day}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="总时长" prop="daytime">
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'WorkTimeTest',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        t_a: {
          begin_day: null,
          begin_time: null,
          time: null,
          time2: null,
        },
        infolist: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/system/CalendarTmeTest/workTimeTest?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      workTimeTestSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/oa/system/CalendarTmeTest/workTimeTestSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
